/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package seminario.util;

import java.io.IOException;
import java.io.OutputStream;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;

/**
 *
 * @author bpmlab
 */
public class PdfUtil {

    public static void exportaPDF(byte[] bytes) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        HttpServletResponse response
                = (HttpServletResponse) externalContext.getResponse();
        response.setContentType("application/pdf");
        try {
            OutputStream output = response.getOutputStream();
            output.write(bytes);
            IOUtils.closeQuietly(output);
        } catch (IOException e) {
        }
    }
}
